// JavaScript Document
function disable(){
	document.getElementById("standardTest").disabled = true; 
	
}



window.onload = function() {

			var form = document.getElementById("formative");
	
	// Check for LocalStorage support.			
if ((localStorage) && (form != null)){
		// Populate the form fields
	// Get the form
		populateForm();

		

		// Event listener for when the bookings form is submitted.
		form.addEventListener("submit", function() {
			saveData(form);
			chooseNext();
		});
	}
}

// Save the form data in LocalStorage.

function saveData() {
	// Fetch the input elements.
	var name = document.getElementById("name");
	var radioChoice1 = document.getElementById("radio-choice-1");
	var radioChoice2 = document.getElementById("radio-choice-2");

// Store the values.
localStorage.setItem("name", name.value);
if (radioChoice1.checked)
{
localStorage.setItem("radio-choice-1", radioChoice1.value);
}
else {
	localStorage.removeItem("radio-choice-1")
	}
if (radioChoice2.checked)
{
localStorage.setItem("radio-choice-2", radioChoice2.value);
}
else {
	localStorage.removeItem("radio-choice-2")
	}
}

// Attempt to populate the form using data stored in LocalStorage.
function populateForm() {
	
	// Fetch the input elements.
	var name = document.getElementById("name");
	var radioChoice1= document.getElementById("radio-choice-1");
	var radioChoice2 = document.getElementById("radio-choice-2");
	// Retrieve the saved data and update the values of the form
	// fields.
	if (localStorage.getItem("name") != null){
		name.value = localStorage.getItem("name");
			}

	if (localStorage.getItem("radio-choice-1")!= null)  {
		 radioChoice1.checked = true;
	}
	if (localStorage.getItem("radio-choice-2")!= null)  {
			radioChoice2.checked  = true;
			}

}

function chooseNext() {

// Store the values.
if (localStorage.getItem("radio-choice-1")!= null) {
//go harder
goNextTask();
alert("correct");
}

else {
//go easier
alert("Incorrect\nPlease try again");
}
}